package com.ruoyi.view.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.view.domain.GyStatistics;
import com.ruoyi.view.service.IGyStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * gy_statisticsController
 *
 * @author ruoyi
 * @date 2023-04-11
 */
@Controller
@RequestMapping("/view/gy_statistics")
public class GyStatisticsController extends BaseController
{
    private String prefix = "data-analysis/gy_statistics";

    @Autowired
    private IGyStatisticsService gyStatisticsService;

    @RequiresPermissions("data-analysis:gy_statistics:view")
    @GetMapping()
    public String gy_statistics()
    {
        return prefix + "/gy_statistics";
    }

    /**
     * 查询gy_statistics列表
     */
//    @RequiresPermissions("data-analysis:gy_statistics:list")
    @CrossOrigin
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(GyStatistics gyStatistics)
    {
//        startPage();
        List<GyStatistics> list = gyStatisticsService.selectGyStatisticsList(gyStatistics);
        return getDataTable(list);
    }

    /**
     * 导出gy_statistics列表
     */
    @RequiresPermissions("data-analysis:gy_statistics:export")
    @Log(title = "gy_statistics", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GyStatistics gyStatistics)
    {
        List<GyStatistics> list = gyStatisticsService.selectGyStatisticsList(gyStatistics);
        ExcelUtil<GyStatistics> util = new ExcelUtil<GyStatistics>(GyStatistics.class);
        return util.exportExcel(list, "gy_statistics数据");
    }

    /**
     * 新增gy_statistics
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存gy_statistics
     */
    @RequiresPermissions("data-analysis:gy_statistics:add")
    @Log(title = "gy_statistics", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GyStatistics gyStatistics)
    {
        return toAjax(gyStatisticsService.insertGyStatistics(gyStatistics));
    }

    /**
     * 修改gy_statistics
     */
    @RequiresPermissions("data-analysis:gy_statistics:edit")
    @GetMapping("/edit/{weatherTime}")
    public String edit(@PathVariable("weatherTime") String weatherTime, ModelMap mmap)
    {
        GyStatistics gyStatistics = gyStatisticsService.selectGyStatisticsByWeatherTime(weatherTime);
        mmap.put("gyStatistics", gyStatistics);
        return prefix + "/edit";
    }

    /**
     * 修改保存gy_statistics
     */
    @RequiresPermissions("data-analysis:gy_statistics:edit")
    @Log(title = "gy_statistics", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GyStatistics gyStatistics)
    {
        return toAjax(gyStatisticsService.updateGyStatistics(gyStatistics));
    }

    /**
     * 删除gy_statistics
     */
    @RequiresPermissions("data-analysis:gy_statistics:remove")
    @Log(title = "gy_statistics", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gyStatisticsService.deleteGyStatisticsByWeatherTimes(ids));
    }
}
